#ifndef _I2C_INTERNAL_H_
#define _I2C_INTERNAL_H_

#include "types.h"
#include "platform_i2c.h"

#define ICOAR(base)        (*((volatile uint32_t *)(base + 0x000)))
#define ICIMR(base)        (*((volatile uint32_t *)(base + 0x004)))
#define ICSTR(base)        (*((volatile uint32_t *)(base + 0x008)))
#define ICCLKL(base)       (*((volatile uint32_t *)(base + 0x00c)))
#define ICCLKH(base)       (*((volatile uint32_t *)(base + 0x010)))
#define ICCNT(base)        (*((volatile uint32_t *)(base + 0x014)))
#define ICDRR(base)        (*((volatile uint32_t *)(base + 0x018)))
#define ICSAR(base)        (*((volatile uint32_t *)(base + 0x01c)))
#define ICDXR(base)        (*((volatile uint32_t *)(base + 0x020)))
#define ICMDR(base)        (*((volatile uint32_t *)(base + 0x024)))
#define ICIVR(base)        (*((volatile uint32_t *)(base + 0x028)))
#define ICEMDR(base)       (*((volatile uint32_t *)(base + 0x02c)))
#define ICPSC(base)        (*((volatile uint32_t *)(base + 0x030)))
#define ICREVID1(base)     (*((volatile uint32_t *)(base + 0x034)))
#define ICREVID2(base)     (*((volatile uint32_t *)(base + 0x038)))
#define ICPFUNC(base)      (*((volatile uint32_t *)(base + 0x048)))
#define ICPDIR(base)       (*((volatile uint32_t *)(base + 0x04c)))
#define ICPDIN(base)       (*((volatile uint32_t *)(base + 0x050)))
#define ICPDOUT(base)      (*((volatile uint32_t *)(base + 0x054)))
#define ICPDSET(base)      (*((volatile uint32_t *)(base + 0x058)))
#define ICPDCLR(base)      (*((volatile uint32_t *)(base + 0x05c)))



// Register fields
#define ICSTR_AL  (uint32_t)0x01
#define ICSTR_NACK    (uint32_t)0x02
#define ICSTR_ARDY    (uint32_t)0x04
#define ICSTR_ICRRDY    (uint32_t)0x08
#define ICSTR_ICXRDY    (uint32_t)0x10
#define ICSTR_STOP      (uint32_t)0x20
#define ICSTR_BUS_BUSY  (uint32_t)0x1000
#define ICSTR_NACK_SENT (uint32_t)0x2000

#define ICMDR_BIT_COUNT  0x00  // 8-bit data
#define ICMDR_IRS        0x20
#define ICMDR_TX_MODE    0x200
#define ICMDR_MASTER     0x400
#define ICMDR_STOP       0x800
#define ICMDR_START      0x2000
#define ICMDR_NACK_MODE  0x8000




#endif
